package com.example.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class MyReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        //获取到当前广播的事件类型
        String action = intent.getAction();
        //判断当前广播事件类型
        if(action.equals(Intent.ACTION_SCREEN_ON)) {
            Log.i("TAG", "屏幕锁屏了");
        } else if (action.equals(Intent.ACTION_SCREEN_OFF)) {
            Log.i("TAG" , "屏幕解锁了");
        }

    }
}
